{% extends "base.html" %}

{% block title %}{% endblock title %}

{% block head %}<script src="/js/common.js"></script>
<script src="/js/tweet.js"></script>
{% if token_user.geo_enabled %}<script src="/js/geo.js"></script>{% endif %}
<script type="text/javascript">
$(function(){
	var active=false;
	var count=18;
	$('.tweet').live('click', function(){
		var ths=$(this);
		var sid =ths.attr('sid');
		var tid =ths.attr('tid');
		var id=sid?sid:tid;
		var done=ths.data('done');
		if(!done&&!active){
			active=true;
			startTinyTip('Loading...');
			$.ajax({
				'type':'GET',
				'url':'/x/retweeted_by/'+id+'?count='+count,
				'dataType':'json',
				'success':function(d){
					active=false;
					if(d&&d.success){
						ths.append(d.retweeted_by);
						ths.data('done',true);
						endTinyTip('Loaded.');
					}else{
						endTinyTip('Error!');
					}
					ths.css('cursor','auto');
				},
				'error':function(){
					active=false;
					endTinyTip('Error!');
				}
			});
		}
	});
});
$(function(){
	//more
	var m = more('/x/retweets/{{ which }}/more', {'max_id': {{ max_id|to_json }} } );
	$('#pagination .more').live('click', function(e){
		m.next();
		e.preventDefault();return false;
	});
	var max_more=5, preload=50+50;
	$(window).bind('scroll',function(){
		if( m.count<max_more && ($('body').height()-preload) < ($(window).height()+$(window).scrollTop()) ){
			m.next();
		}
	});
	
	//refresh
	var ref=refresh('/x/retweets/{{ which }}/refresh', {'since_id':{{ since_id|to_json }} });
	ref.start();
	$('#Notifier').click(function(e){
		ref.show();
		e.preventDefault();return false;
	});
});
</script>
<style type="text/css">.tweet{cursor:pointer;}</style>
{% if owner_user %}{% include "user-style.html" %}{% endif %}
{% endblock head %}

{% block main %}
{% include "tweet-form.html" %}
{% include "main-nav.html" %}
<div id="Timeline">
	{% ifequal where "retweeted_by_me" %}<div id="Tlheading">Retweets by you</div>{% endifequal %}
	{% ifequal where "retweeted_to_me" %}<div id="Tlheading">Retweets by others</div>{% endifequal %}
	{% ifequal where "retweeted_of_me" %}<div id="Tlheading">Your tweets, retweeted</div>{% endifequal %}
	<div id="Notifier"></div>
	<ul class="tweets">
	{% if timeline %}
	{% for tweet in timeline %}
		{% include "tweet.html" %}
	{% endfor %}
	{% else %}
		<li class="nothing">No tweets here.</li>
	{% endif %}
	</ul>
	{% if max_id %}<div id="pagination"><img class="loading" src="/images/loading.gif" /><a class="more" href="{{ self.current }}?max_id={{ max_id }}">More</a></div>{% endif %}
</div>
{% endblock main%}

{% block side %}
{% include "side.html" %}
{% endblock side %}